﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Collections.Generic;

using Business;

namespace Data
{

    public class DataEvento
    {
        public DataEvento()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        

        public bool insertPalcoEvento(int eventoID, int palcoID)
        {
            Connect c = new Connect();
            bool value = false;
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "INSERT INTO EventoPalco (Evento_idEvento,Palco_idPalco) VALUES (" + eventoID + "," + palcoID + ")";
                int i = command.ExecuteNonQuery();
                if (i > 0) value = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return value;
        }

        public bool removePalcoEvento(int eventoID, int palcoID)
        {
            Connect c = new Connect();
            bool value = false;
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "DELETE FROM EventoPalco WHERE Evento_idEvento=" + eventoID + " AND Palco_idPalco=" + palcoID;
                int i = command.ExecuteNonQuery();
                if (i > 0) value = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return value;
        }


        public bool insertArtistEvent(int eventID, int artistID)
        {
            bool val = false;
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "INSERT INTO EventoArtista (Evento_idEvento,Artista_idArtista)VALUES (" + eventID + "," + artistID+")";
                int i = command.ExecuteNonQuery();
                if (i > 0) val = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return val;
        }

        public bool removeArtistEvent(int eventID, int artistID)
        {
            bool value = false;
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();

                command.CommandText = "DELETE FROM EventoArtista WHERE Evento_idEvento=" + eventID + " AND Artista_idArtista=" + artistID;
                int i = command.ExecuteNonQuery();
                if (i > 0) value = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return value;
        }

        public List<String> getCategoriasEvento()
        {
            List<String> lc = new List<String>();
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT categoria FROM catEvento";
                SqlDataReader leitor = command.ExecuteReader();
                while (leitor.Read())
                {
                    if (!leitor.IsDBNull(0))
                        lc.Add(Convert.ToString(leitor[0]));
                }
                leitor.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return lc;
        }

        public String getCat(int idCat)
        {
            Connect c = new Connect();
            String cat = "";
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT categoria FROM catEvento WHERE idcatEvento=" + idCat;
                SqlDataReader leitor = command.ExecuteReader();
                if (leitor.Read())
                {
                    if(!leitor.IsDBNull(0))
                         cat = Convert.ToString(leitor[0]);
                }
                leitor.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return cat;
        }

        public String getOrg(int idOrg)
        {
            Connect c = new Connect();
            String org = "";
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT nome FROM Organizador WHERE idOrganizador=" + idOrg;
                SqlDataReader leitor = command.ExecuteReader();
                if (leitor.Read())
                    org = Convert.ToString(leitor[0]);
                leitor.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return org;
        }

        public int getIdCat(String cat)
        {
            Connect c = new Connect();
            int idcat = -1;
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT idcatEvento FROM catEvento WHERE categoria='" + cat + "'";
                SqlDataReader leitor = command.ExecuteReader();
                if (leitor.Read())
                    idcat = Convert.ToInt16(leitor[0]);
                leitor.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return idcat;
        }

        public Evento getEventoByID(int eventoID)
        {
            Connect c = new Connect();
            Evento evento = new Evento();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT idEvento, nome, dataInicio, dataFim, descricao, preco, catEvento_idcatEvento, Organizador_idOrganizador, cartaz, link, nPessoas, nComentarios, status FROM Evento WHERE (idEvento = "+eventoID+")";

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    int eventID = Convert.ToInt32(reader[0]);
                    String cat = getCat(Convert.ToInt16(reader[6]));
                    DateTime dataInicio = new DateTime();
                    DateTime dataFim = new DateTime();
                    String descricaoEvento = "";
                    float precoEvento = -1;
                    int organizadorID = -1;
                    String cartaz = "";
                    String linkEvento = "";
                    int nPessoas = -1;
                    int nComments = -1;
                    String nome = Convert.ToString(reader[1]);


                    if (!reader.IsDBNull(2))
                        dataInicio = Convert.ToDateTime(reader[2]);
                    if (!reader.IsDBNull(3))
                        dataFim = Convert.ToDateTime(reader[3]);
                    if (!reader.IsDBNull(4))
                        descricaoEvento = Convert.ToString(reader[4]);
                    if (!reader.IsDBNull(5))
                        precoEvento = (float)Convert.ToDouble(reader[5]);
                    if (!reader.IsDBNull(7))
                        organizadorID = Convert.ToInt16(reader[7]);
                    if (!reader.IsDBNull(8))
                        cartaz = Convert.ToString(reader[8]);
                    if (!reader.IsDBNull(9))
                        linkEvento = Convert.ToString(reader[9]);
                    if (!reader.IsDBNull(10))
                        nPessoas = Convert.ToInt16(reader[10]);
                    if (!reader.IsDBNull(11))
                        nComments = Convert.ToInt16(reader[11]);
                    
                    
                    int status = Convert.ToInt16(reader[12]);

                    evento = new Evento(nome, dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                    evento.setID(eventoID);
                    evento.setStatus(status);
                }

                reader.Close();
                conn.Close();

            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
            }

            return evento;
        }

        public int insertEvento(Evento e)
        {
            int value = -1;
            Connect c = new Connect();
            String str="";
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();

                int cat = getIdCat(e.getCategoria());

                command.CommandText = "INSERT INTO Evento (nome, dataInicio, dataFim, descricao, preco, catEvento_idcatEvento, link, status) VALUES " + " ('" + e.getNome() + "','" + e.getDataInicio() + "','" + e.getDataFim() + "','" + e.getDescricao() + "'," + e.getPreco().ToString().Replace(",", ".") + "," + cat + ",'" + e.getLink() + "',1)";
                
                int i = command.ExecuteNonQuery();
                
                command.CommandText = "SELECT MAX(idEvento) FROM Evento";
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                    value = Convert.ToInt16(reader[0]);
                reader.Close();
                conn.Close();

            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return value;
        }

        public bool updateEvento(Evento e)
        {
            bool value = false;
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();

                int cat = getIdCat(e.getCategoria());

                command.CommandText = "UPDATE Evento SET nome='" + e.getNome() + "',dataInicio='" + e.getDataInicio() + "',dataFim='"+e.getDataFim()+"',descricao='"+e.getDescricao()+"',preco="+e.getPreco().ToString().Replace(",",".")+",catPalco_idcatPalco=" + cat + ",Organizador_idOrganizor="+e.getOrganizadorID()+",cartaz='"+e.getCartaz()+"',link='" + e.getLink() + "',nPessoas="+e.getNPessoas()+",nComentarios=" + e.getNComentarios() + ",status=" + e.getStatus() + " WHERE (idEvento=" + e.getID() + ")";
                int i = command.ExecuteNonQuery();
                if (i > 0) value = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return value;
        }

        public bool setEstadoEvento(int eventID, int novoEstado)
        {
            bool value = false;
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();

                command.CommandText = "UPDATE Evento SET status=" + novoEstado + " WHERE (idEvento=" + eventID + ")";
                int i = command.ExecuteNonQuery();
                if (i > 0) value = true;
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return value;
        }

        public ListaEvento getListaEvento(int status)
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                if (status == -10)
                    command.CommandText = "Select * from Evento";
                else
                    command.CommandText = "Select * from Evento where status=" + status;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    String cat = "";
                    if (!reader.IsDBNull(6))
                        getCat(Convert.ToInt16(reader[6]));
                    DateTime dataInicio = new DateTime();
                    DateTime dataFim = new DateTime();
                    String descricaoEvento = "";
                    float precoEvento = -1;
                    int organizadorID = -1;
                    String cartaz = "";
                    String linkEvento = "";
                    int nPessoas = -1;
                    int nComments = -1;

                    if (!reader.IsDBNull(2))
                        dataInicio = Convert.ToDateTime(reader[2]);
                    if (!reader.IsDBNull(3))
                        dataFim = Convert.ToDateTime(reader[3]);
                    if (!reader.IsDBNull(4))
                        descricaoEvento = Convert.ToString(reader[4]);
                    if (!reader.IsDBNull(5))
                        precoEvento = (float)Convert.ToDouble(reader[5]);
                    if (!reader.IsDBNull(7))
                        organizadorID = Convert.ToInt16(reader[7]);
                    if (!reader.IsDBNull(8))
                        cartaz = Convert.ToString(reader[8]);
                    if (!reader.IsDBNull(9))
                        linkEvento = Convert.ToString(reader[9]);
                    if (!reader.IsDBNull(10))
                        nPessoas = Convert.ToInt16(reader[10]);
                    if (!reader.IsDBNull(11))
                        nComments = Convert.ToInt16(reader[11]);

                    e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                    e.setID(Convert.ToInt32(reader[0]));
                    e.setStatus(Convert.ToInt16(reader[12]));
                    le.addEvento(e);
                }
                reader.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

        public ListaEvento getTopTen()
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "Select * from TopTenEvents";
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    String cat = "";
                    if(!reader.IsDBNull(6))
                        getCat(Convert.ToInt16(reader[6]));
                    DateTime dataInicio = new DateTime();
                    DateTime dataFim = new DateTime();
                    String descricaoEvento = "";
                    float precoEvento = -1;
                    int organizadorID = -1;
                    String cartaz = "";
                    String linkEvento = "";
                    int nPessoas = -1;
                    int nComments = -1;

                    if (!reader.IsDBNull(2))
                        dataInicio = Convert.ToDateTime(reader[2]);
                    if (!reader.IsDBNull(3))
                        dataFim = Convert.ToDateTime(reader[3]);
                    if (!reader.IsDBNull(4))
                        descricaoEvento = Convert.ToString(reader[4]);
                    if (!reader.IsDBNull(5))
                        precoEvento = (float)Convert.ToDouble(reader[5]);
                    if (!reader.IsDBNull(7))
                        organizadorID = Convert.ToInt16(reader[7]);
                    if(!reader.IsDBNull(8))
                        cartaz = Convert.ToString(reader[8]);
                    if (!reader.IsDBNull(9))
                        linkEvento = Convert.ToString(reader[9]);
                    if (!reader.IsDBNull(10))
                        nPessoas = Convert.ToInt16(reader[10]);
                    if (!reader.IsDBNull(11))
                        nComments = Convert.ToInt16(reader[11]);
                    
                    e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat,organizadorID,cartaz , linkEvento, nPessoas, nComments);
                    e.setID(Convert.ToInt32(reader[0]));
                    e.setStatus(Convert.ToInt16(reader[12]));
                    le.addEvento(e);
                }
                reader.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

        public ListaEvento getTopTenCom()
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "Select * from Top10ComEvents";
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    String cat = "";
                    if (!reader.IsDBNull(6))
                        getCat(Convert.ToInt16(reader[6]));
                    DateTime dataInicio = new DateTime();
                    DateTime dataFim = new DateTime();
                    String descricaoEvento = "";
                    float precoEvento = -1;
                    int organizadorID = -1;
                    String cartaz = "";
                    String linkEvento = "";
                    int nPessoas = -1;
                    int nComments = -1;

                    if (!reader.IsDBNull(2))
                        dataInicio = Convert.ToDateTime(reader[2]);
                    if (!reader.IsDBNull(3))
                        dataFim = Convert.ToDateTime(reader[3]);
                    if (!reader.IsDBNull(4))
                        descricaoEvento = Convert.ToString(reader[4]);
                    if (!reader.IsDBNull(5))
                        precoEvento = (float)Convert.ToDouble(reader[5]);
                    if (!reader.IsDBNull(7))
                        organizadorID = Convert.ToInt16(reader[7]);
                    if (!reader.IsDBNull(8))
                        cartaz = Convert.ToString(reader[8]);
                    if (!reader.IsDBNull(9))
                        linkEvento = Convert.ToString(reader[9]);
                    if (!reader.IsDBNull(10))
                        nPessoas = Convert.ToInt16(reader[10]);
                    if (!reader.IsDBNull(11))
                        nComments = Convert.ToInt16(reader[11]);

                    e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                    e.setID(Convert.ToInt32(reader[0]));
                    e.setStatus(Convert.ToInt16(reader[12]));
                    le.addEvento(e);
                }
                reader.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

        public ListaEvento getSearchListaEvento(String nome)
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                
                command.CommandText = "Select * from Evento where nome LIKE '%"+ nome+"%'";
                
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    String cat = "";
                    if (!reader.IsDBNull(6))
                        getCat(Convert.ToInt16(reader[6]));
                    DateTime dataInicio = new DateTime();
                    DateTime dataFim = new DateTime();
                    String descricaoEvento = "";
                    float precoEvento = -1;
                    int organizadorID = -1;
                    String cartaz = "";
                    String linkEvento = "";
                    int nPessoas = -1;
                    int nComments = -1;

                    if (!reader.IsDBNull(2))
                        dataInicio = Convert.ToDateTime(reader[2]);
                    if (!reader.IsDBNull(3))
                        dataFim = Convert.ToDateTime(reader[3]);
                    if (!reader.IsDBNull(4))
                        descricaoEvento = Convert.ToString(reader[4]);
                    if (!reader.IsDBNull(5))
                        precoEvento = (float)Convert.ToDouble(reader[5]);
                    if (!reader.IsDBNull(7))
                        organizadorID = Convert.ToInt16(reader[7]);
                    if (!reader.IsDBNull(8))
                        cartaz = Convert.ToString(reader[8]);
                    if (!reader.IsDBNull(9))
                        linkEvento = Convert.ToString(reader[9]);
                    if (!reader.IsDBNull(10))
                        nPessoas = Convert.ToInt16(reader[10]);
                    if (!reader.IsDBNull(11))
                        nComments = Convert.ToInt16(reader[11]);

                    e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                    e.setID(Convert.ToInt32(reader[0]));
                    e.setStatus(Convert.ToInt16(reader[12]));
                    le.addEvento(e);
                }
                reader.Close();
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

        public ListaEvento getEventosByArtistaID(int artistID)
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            List<int> lei = new List<int>();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT Evento_idEvento FROM EventoArtista WHERE Artista_idArtista=" + artistID;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    lei.Add(Convert.ToInt16(reader[0]));
                }
                reader.Close();

                foreach (int ei in lei)
                {
                    command.CommandText = "Select * from Evento where idEvento=" + ei;
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        String cat = "";
                        if (!reader.IsDBNull(6))
                            getCat(Convert.ToInt16(reader[6]));
                        DateTime dataInicio = new DateTime();
                        DateTime dataFim = new DateTime();
                        String descricaoEvento = "";
                        float precoEvento = -1;
                        int organizadorID = -1;
                        String cartaz = "";
                        String linkEvento = "";
                        int nPessoas = -1;
                        int nComments = -1;

                        if (!reader.IsDBNull(2))
                            dataInicio = Convert.ToDateTime(reader[2]);
                        if (!reader.IsDBNull(3))
                            dataFim = Convert.ToDateTime(reader[3]);
                        if (!reader.IsDBNull(4))
                            descricaoEvento = Convert.ToString(reader[4]);
                        if (!reader.IsDBNull(5))
                            precoEvento = (float)Convert.ToDouble(reader[5]);
                        if (!reader.IsDBNull(7))
                            organizadorID = Convert.ToInt16(reader[7]);
                        if (!reader.IsDBNull(8))
                            cartaz = Convert.ToString(reader[8]);
                        if (!reader.IsDBNull(9))
                            linkEvento = Convert.ToString(reader[9]);
                        if (!reader.IsDBNull(10))
                            nPessoas = Convert.ToInt16(reader[10]);
                        if (!reader.IsDBNull(11))
                            nComments = Convert.ToInt16(reader[11]);

                        e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                        e.setID(Convert.ToInt32(reader[0]));
                        e.setStatus(Convert.ToInt16(reader[12]));
                        le.addEvento(e);
                    }
                    reader.Close();   
                }
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

        public ListaEvento getEventosByPalcoID(int palcoID)
        {
            Evento e = null;
            Connect c = new Connect();
            ListaEvento le = new ListaEvento();
            List<int> lei = new List<int>();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT Evento_idEvento FROM EventoPalco WHERE Palco_idPalco=" + palcoID;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    lei.Add(Convert.ToInt16(reader[0]));
                }
                reader.Close();

                foreach (int ei in lei)
                {
                    command.CommandText = "Select * from Evento where idEvento=" + ei;
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        String cat = "";
                        if (!reader.IsDBNull(6))
                            getCat(Convert.ToInt16(reader[6]));
                        DateTime dataInicio = new DateTime();
                        DateTime dataFim = new DateTime();
                        String descricaoEvento = "";
                        float precoEvento = -1;
                        int organizadorID = -1;
                        String cartaz = "";
                        String linkEvento = "";
                        int nPessoas = -1;
                        int nComments = -1;

                        if (!reader.IsDBNull(2))
                            dataInicio = Convert.ToDateTime(reader[2]);
                        if (!reader.IsDBNull(3))
                            dataFim = Convert.ToDateTime(reader[3]);
                        if (!reader.IsDBNull(4))
                            descricaoEvento = Convert.ToString(reader[4]);
                        if (!reader.IsDBNull(5))
                            precoEvento = (float)Convert.ToDouble(reader[5]);
                        if (!reader.IsDBNull(7))
                            organizadorID = Convert.ToInt16(reader[7]);
                        if (!reader.IsDBNull(8))
                            cartaz = Convert.ToString(reader[8]);
                        if (!reader.IsDBNull(9))
                            linkEvento = Convert.ToString(reader[9]);
                        if (!reader.IsDBNull(10))
                            nPessoas = Convert.ToInt16(reader[10]);
                        if (!reader.IsDBNull(11))
                            nComments = Convert.ToInt16(reader[11]);

                        e = new Evento(Convert.ToString(reader[1]), dataInicio, dataFim, descricaoEvento, precoEvento, cat, organizadorID, cartaz, linkEvento, nPessoas, nComments);
                        e.setID(Convert.ToInt32(reader[0]));
                        e.setStatus(Convert.ToInt16(reader[12]));
                        le.addEvento(e);
                    }
                    reader.Close();
                }
                conn.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return le;
        }

    }

}